Track manipulation filter
- Copyright (C) 2005 Olaf Klein, o.b.klein@gpsbabel.org
+ Copyright (C) 2005-2006 Olaf Klein, o.b.klein@gpsbabel.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
2005-07-26: implemented move option
2005-07-26: implemented merge option
2005-07-29: warning fixes
- 2005-08-01: Add 'static' qualifier when we can (RJL)
- 2005-10-04: Add filterdefs to hold protos for filter functions... (RJL)
+ 2005-08-01: Add 'static' qualifier when we can (robertl)
+ 2005-10-04: Add filterdefs to hold protos for filter functions... (robertl)
2005-10-04: Fix range-check max. value; exit filter, if no more tracks left
- 2006-04-06: Add fix, course, and speed options
+ 2006-04-06: Add fix, course, and speed options (parkrrrr)
2006-06-01: Add name option
+ 2007-01-08: if not really needed disable check for valid timestamps
+ (based on patch from Vladimir Kondratiev)
*/
#include <ctype.h>
static int track_pts = 0;
static int opt_interval = 0;
static int opt_distance = 0;
+static char need_time; /* initialized within trackfilter_init */
/*******************************************************************************
* helpers
track_pts++;
wpt = (waypoint *)elem;
- if (wpt->creation_time == 0)
- fatal(MYNAME "-init: Found track point without time!\n");
+ is_fatal((need_time != 0) && (wpt->creation_time == 0),
+ MYNAME "-init: Found track point without time!");
i++;
if (i == 1)
if (i == track->rte_waypt_ct)
track_list[track_ct].last_time = wpt->creation_time;
- if ((prev != NULL) && (prev->creation_time > wpt->creation_time))
+ if ((need_time != 0) && (prev != NULL) && (prev->creation_time > wpt->creation_time))
{
if (opt_merge == NULL)
fatal(MYNAME "-init: Track points badly ordered (timestamp)!\n");
int count = track_count();
+/*
+ * check time presence only if required. Options that NOT require time:
+ *
+ * - opt_title (!!! only if no format specifier is present !!!)
+ * - opt_course
+ * - opt_name
+ */
+ need_time = (
+ opt_merge || opt_pack || opt_split || opt_sdistance ||
+ opt_move || opt_start || opt_stop || opt_fix || opt_speed ||
+ (trackfilter_opt_count() == 0) /* do pack by default */
+ );
+ /* in case of a formated title we also need valid timestamps */
+ if ((opt_title != NULL) && (strchr(opt_title, '%') != NULL)) need_time = 1;
+
track_ct = 0;
track_pts = 0;
/* check all tracks for time and order (except merging) */
track_disp_all(trackfilter_fill_track_list_cb, NULL, NULL);
- qsort(track_list, track_ct, sizeof(*track_list), trackfilter_init_qsort_cb);
+ if (need_time)
+ qsort(track_list, track_ct, sizeof(*track_list), trackfilter_init_qsort_cb);
}
}